<?php
namespace Home\Controller;

class ServiceController extends HomeController {

    public function index(){   	

        $banner = M("Ad")->where(array('id'=>8))->find();
        $this->assign('banner',$banner);

        $this->display();

    }

    public function item(){
        $cate = I('get.id');
        
        if ($cate=='' || !is_numeric($cate)) {
            $this->error('参数错误');            
        }

        $item = M('Category')->where(array('id'=>$cate))->find();
        if (!$item) {
            $this->error('项目不存在');   
        }

        $this->assign('item',$item);

        $map['cid'] = $cate;

        $this->assign('cateID',$cate);
        $map['del'] = 0;
        $map['show'] = 1;
        $obj = M('Goods');
        $count = $obj->where($map)->count();
        import("Common.ORG.AmPage");
        $page = new \Page($count, 25);
        $show = $page->show();
        $list = $obj->where($map)->order('sort asc,id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
        $this->assign('list',$list);
        $this->assign('page',$show);

        $banner = M("Ad")->where(array('id'=>8))->find();
        $this->assign('banner',$banner);

        $this->display();
    }
    

    public function view(){
    	$id = I('get.id');
    	if ($id=='' || !is_numeric($id)) {
    		$this->error('参数错误');
    	}

    	$map['id'] = $id;
    	$map['show'] = 1;
    	$map['del'] = 0;    	
    	$list = M('Goods')->where($map)->find();
    	if (!$list) {
    		$this->error('信息不存在');
    	}else{
            $this->assign('list', $list);

            $item = M('Category')->where(array('id'=>$list['cid']))->find();
            if (!$item) {
                $this->error('项目不存在');   
            }
            $this->assign('item',$item);

            $banner = M("Ad")->where(array('id'=>8))->find();
            $this->assign('banner',$banner);
    		$this->display();
    	}
    }
}